#!/bin/sh
#
# 内存检查脚本
#
# 用法：$0 <testin> <progout> <commands...>

TESTIN="$1"; shift
PROGOUT="$1"; shift

if [ -f "$TESTIN" ]; then
    exec valgrind --leak-check=full --undef-value-errors=yes --track-origins=yes --xml=yes --xml-file=valgrind.xml -- "$@" < "$TESTIN" > "$PROGOUT"
else
    exec valgrind --leak-check=full --undef-value-errors=yes --track-origins=yes --xml=yes --xml-file=valgrind.xml -- "$@" > "$PROGOUT"
fi
